<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>设置/获取替代字符</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.mb-strwidth.html">« mb_strwidth</a></li>
      <li style="float: right;"><a href="function.mb-substr-count.html">mb_substr_count »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.mbstring.html">多字节字符串 函数</a></li>
    <li>设置/获取替代字符</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.mb-substitute-character" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mb_substitute_character</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.6, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">mb_substitute_character</span> &mdash; <span class="dc-title">设置/获取替代字符</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.mb-substitute-character-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>mb_substitute_character</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$substchar</code><span class="initializer"> = mb_substitute_character()</span></span>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">
   当输入字符的编码是无效的，或者字符代码不存在于输出的字符编码中时，可以为其指定一个替代字符。
   无效字符可以被替换为 <strong><code>null</code></strong>（不输出）、<span class="type">string</span> 或者 <span class="type">integer</span> 值（Unicode 字符代码的值）。
  </p>
  <p class="para">
   该设置会影响 <span class="function"><a href="function.mb-convert-encoding.html" class="function">mb_convert_encoding()</a></span>、
   <span class="function"><a href="function.mb-convert-variables.html" class="function">mb_convert_variables()</a></span>、
   <span class="function"><a href="function.mb-output-handler.html" class="function">mb_output_handler()</a></span>
   和 <span class="function"><a href="function.mb-send-mail.html" class="function">mb_send_mail()</a></span>。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.mb-substitute-character-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">substchar</code></dt>

     <dd>

      <p class="para">
       指定 Unicode 值为一个 <span class="type">integer</span>，或者是以下<span class="type"><span class="type 字符串">字符串</span></span>中的一个：
       <ul class="itemizedlist">
        <li class="listitem">
         <span class="simpara">
          <code class="literal">&quot;none&quot;</code>:：不输出
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <code class="literal">&quot;long&quot;</code>：输出字符代码的值（比如：<code class="literal">U+3000</code>、<code class="literal">JIS+7E7E</code>）
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <code class="literal">&quot;entity&quot;</code>：输出字符的实体（比如：<code class="literal">&amp;#x200;</code>）
         </span>
        </li>
       </ul>
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.mb-substitute-character-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   如果设置了 <code class="parameter">substchar</code>，在成功时返回 <strong><code>true</code></strong>，失败时返回 <strong><code>false</code></strong>。
   如果没有设置 <code class="parameter">substchar</code>，它将返回当前设置。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.mb-substitute-character-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2584">
    <p><strong>示例 #1 <span class="function"><strong>mb_substitute_character()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*&nbsp;设置为&nbsp;Unicode&nbsp;U+3013&nbsp;(GETA&nbsp;MARK)&nbsp;*/<br /></span><span style="color: #0000BB">mb_substitute_character</span><span style="color: #007700">(</span><span style="color: #0000BB">0x3013</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;设置十六进制格式&nbsp;*/<br /></span><span style="color: #0000BB">mb_substitute_character</span><span style="color: #007700">(</span><span style="color: #DD0000">"long"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;显示当前设置&nbsp;*/<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">mb_substitute_character</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


</div></div></div></body></html>